#ifndef _HARDWARE_CAIRUI_20170809_
#define _HARDWARE_CAIRUI_20170809_

#include <stdint.h>
#include <string>

static const int PERF_TEST_FLAG_OFFSET   = 15 * 1024;
static const int SN_OFFSET   = 16 * 1024;
static const int MAC_OFFSET  = 17 * 1024;

#define SEEK_TO_OFFSET_END(f, offset)  \
        fseek(f, offset, SEEK_END)
#define SEEK_TO_OFFSET_SET(f, offset)  \
        fseek(f, offset, SEEK_SET)
#define SEEK_TO_OFFSET(f, offset)	\
        SEEK_TO_OFFSET_SET(f, offset)

#define SEEK_TO_PERF_OFFSET(f)  \
        SEEK_TO_OFFSET_SET(f, PERF_TEST_FLAG_OFFSET)

#define SEEK_TO_SN_OFFSET(f)  \
        SEEK_TO_OFFSET_SET(f, SN_OFFSET)
#define SEEK_TO_MAC_OFFSET(f)   \
        SEEK_TO_OFFSET_SET(f, MAC_OFFSET)

#define GET_SN_URL      "slapi.oray.net"
#define GET_SN_PATH     "/kvm/register"
#define GET_MAC_SN_PATH "/kvm/get-sn"

#define DEFAULT_IF  "eth0"
#define ETH_IF 		"eth0"
#define WIFI_IF     "wlan0"
#define WIFI_IF_AP  "wlan1"
/*
 * @brief 获取本地SN号
 * @param sn 返回的SN号
 * @return 返回0代表成功，其他代表获取失败
 */
extern int get_sn_from_local(char* sn);
extern int get_perf_from_local(char* perf);
extern int get_mac(char* mac, int size);
extern int get_cpu_id(char* id);
extern int get_mac_from_local(char* mac);
extern int get_ether_status(bool *isUp);
extern int get_ether_ip(char *ip);
extern int get_version(char *version);
extern int get_model(char *model);

/**
 * @brief 获取网卡ip
 * 
 * @param ifdev 网卡
 * @param ip ip
 * @return int 0正常
 */
int get_if_ip(const char * ifdev,char * ip);

/**
 * @brief 获取网卡mask
 * 
 * @param ifdev 网卡
 * @param ip ip
 * @return int 0正常
 */
int get_if_mask(const char *ifdev, char *ip);

/**
 * @brief 获取网卡mac
 * 
 * @param ifdev 网卡
 * @param mac 
 * @param size 
 * @return int 0正常
 */
int get_if_mac(const char *ifdev, char *mac, int size);



extern std::string get_mtdPath();

#endif
